/* DataSend.java 
* Created on Dec 13, 2012 
*@Author: Mr.Viet 
*@Phone: 01683430426 
*@Email: phamvanvietcdhd@gmail.com
*/ 
package com.session8; 

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketException;


import java.nio.channels.DatagramChannel;

public class DataSend {

	public DataSend() {
	}

	public static void main(String[] args) {
		String data = "Pham van viet";
		DatagramPacket packet = new DatagramPacket(data.getBytes(), data.getBytes().length);
		InetSocketAddress addr = new InetSocketAddress("localhost",2012);
		packet.setSocketAddress(addr);
		try {
			DatagramSocket socket = new DatagramSocket();
			socket.send(packet);
		} catch (SocketException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
